<template>
  <div class="auto" style="margin-top: 10px;border: 1px solid #F2F6FA;">
    <criteria v-ref:criteria>
      <div novalidate class="form-horizontal" partial>
        <p class="flex-between bg-info" style="padding: 8px;">
          <span>换表查询</span>
          <span class="btn btn-link add-postition" @click="$parent.clear()">清空查询条件</span>
        </p>
        <div class="form-group">
          <label class=" col-sm-3 control-label">换表类型</label>
          <div class="col-sm-9">
            <v-select :value.sync="model.f_changemeter_type"
                v-model="model.f_changemeter_type"
                :options='$parent.changeTypes' placeholder='请选择'
                condition="all_换表类型_11 = '{}'"
                close-on-select></v-select>
          </div>
        </div>
        <div class="form-group">
          <label class=" col-sm-3 control-label">新气表类型</label>
          <div class="col-sm-9">
            <v-select :value.sync="model.f_meter_type"
                v-model="model.f_meter_type"
                :options='$parent.metertypes' placeholder='请选择'
                condition="all_新气表类型_13 = '{}'"
                close-on-select></v-select>
          </div>
        </div>
        <div class="form-group">
          <label class=" col-sm-3 control-label">旧气表类型</label>
          <div class="col-sm-9">
            <v-select :value.sync="model.f_meter_type2"
                v-model="model.f_meter_type2"
                :options='$parent.metertypes' placeholder='请选择'
                condition="all_旧气表类型_14 = '{}'"
                close-on-select></v-select>
          </div>
        </div>
        <div class="form-group">
          <label class=" col-sm-3 control-label">旧气表品牌</label>
          <div class="col-sm-9">
            <v-select :value.sync="model.f_meter_brand"
                v-model="model.f_meter_brand"
                :options='$parent.meterbrands' placeholder='请选择'
                condition="all_旧气表品牌_15 = '{}'"
                close-on-select></v-select>
          </div>
        </div>
        <div class="form-group">
          <label class=" col-sm-3 control-label">换表人</label>
          <div class="col-sm-9">
            <v-select :value.sync="model.f_change_operator"
                v-model="model.f_change_operator"
                :options='$parent.changePerson' placeholder='请选择'
                condition="all_换表人_32 = '{}'"
                close-on-select></v-select>
          </div>
        </div>

      </div>
    </criteria>
  </div>
</template>

<script>
import AppData from '../../../../stores/AppData'
export default {
  title: '换表查询条件',
  methods: {
    getArgs () {
      return this.$refs.criteria.search()
    },
    // 清空所有查询条件
    clear () {
      Object.keys(this.$refs.criteria.model).forEach((key) => {
        this.$refs.criteria.model[key] = ''
      })
    }
  },
  computed: {
    changeTypes () {
      return [{label: '全部', value: ''}, ...AppData.getParam('换表类型')]
    },
    metertypes () {
      return [{label: '全部', value: ''}, ...AppData.getParam('气表类型')]
    },
    meterbrands () {
      let arr = []
      AppData.getGasbrand().forEach((item) => {
        let temp = {}
        temp.label = item.label
        temp.value = item.value.f_meter_brand
        arr.push(temp)
      })
      return [{label: '全部', value: ''}, ...arr]
    },
    changePerson () {
      return [{label: '全部', value: ''}, ...AppData.getParam('换表人')]
    }
  }
}
</script>
